﻿<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<form name="regform" id="regform" method="get">
    请输入搜索字符，以空格区分：<input type="text" size=30 name="kw" value="">
    <input type="submit" value="确 定" name="btnSubmit">
</form>

<?php
if ($_GET[kw]!=""){
$keyword=htmlspecialchars($_GET[kw]);
if (	$keyword=="\\"||$keyword=='/'    ||$keyword==":" ||
	$keyword=="*" ||$keyword=="?"    ||$keyword==htmlspecialchars("\"")||
	$keyword==htmlspecialchars('<')  ||$keyword==htmlspecialchars('>') || 
	$keyword=="?") echo "输入非法字符！";
$kwd=explode(" ",$keyword,8);
echo "您输入的搜索字串是：";for ($i=0;$i<=count($kwd)-1;$i++) echo $kwd[$i]." ";

$st=0;  //显示禁止超过200条
$file_handle_htm = fopen("html.htm", "r");
$file_handle_txt = fopen("text.txt", "r");
if (!feof($file_handle_htm)) $htm = fgets($file_handle_htm);
	else echo "Error! File not found";
for ($i=0;$i<=count($kwd)-1;$i++) {$kwdG[$i]=mb_convert_encoding($kwd[$i],"GBK","UTF-8");}
if ($kwd[count($kwd)-1]=="") unset($kwd[count($kwd)-1]);
while (!feof($file_handle_htm)) {
   $htm = fgets($file_handle_htm);
   $txt = fgets($file_handle_txt);
   for ($i=0;$i<=count($kwd)-1;$i++) {
	if(!strpos($txt,$kwdG[$i])) break;
	}
   if ($i==count($kwd)) {
	$st++;echo "<br>".$st.". ".mb_convert_encoding($htm,"UTF-8","GBK");
	}
   if ($st==200) {echo "<br>下面还有喔，但检索到的条目太多，请改进关键词";break;}
   }

echo "<br>搜索成功完成";
}
echo "<br>Incoming.blueink.org FTP Search Engine v0.1. Report bugs to writer greeneleaf6@sina.com";
?>